package com.navi.mould1.controller;
import com.navi.bean.in.ConditionBean;
import com.navi.bean.out.abnormal_time_monitoring.AbnormalTimeMonitoringBean;
import com.navi.bean.out.halm_colorScale_report.HalmColorScaleReportBean;
import com.navi.bean.out.activation_new_report.ActivationNewReportBean;
import com.navi.bean.out.activation_rsnCode_report.ActivationRsnCodeReportBean;
import com.navi.bean.out.erpPicking_report.ErpPickingReportBean;
import com.navi.bean.out.halm_etaTrend_report.HalmEtaTrendReportBean;
import com.navi.bean.out.halm_gearDistribution_report.HalmGearDistributionReportBean;
import com.navi.bean.out.halm_hourEfficiencyTrend_report.HalmHourEfficiencyTrendReportBean;
import com.navi.bean.out.insTask_report.InsTaskReportBean;
import com.navi.bean.out.ivTest_chart_report.IvTestChartReportBean;
import com.navi.bean.out.halm_lineEfficiency_report.HalmLineEfficiencyReportBean;
import com.navi.bean.out.halm_lotEfficiency_report.HalmLotEfficiencyReportBean;
import com.navi.bean.out.kuosan_report.KuosanReportBean;
import com.navi.bean.out.material_report.MaterialReportBean;
import com.navi.bean.out.ooc_report.OocReportBean;
import com.navi.bean.out.oos_report.OosReportBean;
import com.navi.bean.out.pecvd_1_report.PECVD1ReportBean;
import com.navi.bean.out.pecvd_2_report.PECVD2ReportBean;
import com.navi.bean.out.pecvd_3_report.PECVD3ReportBean;
import com.navi.bean.out.pecvd_4_report.PECVD4ReportBean;
import com.navi.bean.out.pecvd_5_report.PECVD5ReportBean;
import com.navi.bean.out.pmTask_report.PmTaskReportBean;
import com.navi.bean.out.powerTrend_chart_report.PowerTrendChartReportBean;
import com.navi.bean.out.productClassify_report.ProductClassifyReportBean;
import com.navi.bean.out.repairOrder_report.RepairOrderReportBean;
import com.navi.bean.out.retAutoIns_report.RetAutoInsReportBean;
import com.navi.bean.out.spc_chart_his_report.SpcChartHisReportBean;
import com.navi.bean.out.spc_chart_report.SpcChartReportBean;
import com.navi.bean.out.spc_cl_report.SpcClReportBean;
import com.navi.bean.out.spc_cpk_report.SpcCpkReportBean;
import com.navi.bean.out.spc_ppk_report.SpcPpkReportBean;
import com.navi.bean.out.spc_report.SpcReportBean;
import com.navi.bean.out.activation_report.ActivationReportBean;
import com.navi.bean.out.twoHourSummary_report.TwoHourSummaryReportBean;
import com.navi.core.util.JacksonUtil;
import com.navi.mould1.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import static com.navi.mould1.reportUtils.reportUtil.getCondition;

@Slf4j
@Controller
@RequestMapping(value = "report")
public class reportController {

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private HttpServletResponse response;



	/*** 组件工艺自动点巡检 - Report **/
	@Autowired
	private IRetAutoInsReportService retAutoInsReportService;
	@ResponseBody
	@RequestMapping(value = "/retAutoIns_report.do", method = RequestMethod.POST)
	public String retAutoIns_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		RetAutoInsReportBean reportBean = new RetAutoInsReportBean();
		reportBean.setGridData(retAutoInsReportService.getGridData(conditions));
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 点巡检任务完成度 - Report **/
	@Autowired
	private IInsTaskReportService insTaskReportService;
	@ResponseBody
	@RequestMapping(value = "/insTask_report.do", method = RequestMethod.POST)
	public String insTask_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		InsTaskReportBean reportBean = new InsTaskReportBean();
		reportBean.setGridData(insTaskReportService.getGridData(conditions));
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 保养任务完成度 - Report **/
	@Autowired
	private IPmTaskReportService pmTaskReportService;
	@ResponseBody
	@RequestMapping(value = "/pmTask_report.do", method = RequestMethod.POST)
	public String pmTask_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		PmTaskReportBean reportBean = new PmTaskReportBean();
		reportBean.setGridData(pmTaskReportService.getGridData(conditions));
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** OOS - Report **/
	@Autowired
	private IOosReportService oosReportService;
	@ResponseBody
	@RequestMapping(value = "/oos_report.do", method = RequestMethod.POST)
	public String oos_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		OosReportBean reportBean = new OosReportBean();
		//try {
		reportBean.setGridData(oosReportService.getGridData(conditions));
		//}catch (Exception e2){
		//	e2.printStackTrace();
		//	oosReportBean.setRtn_code("0000003");
		//	if (e2.getMessage().contains("SQL")) oosReportBean.setRtn_mesg("SQL执行错误");
		//	else oosReportBean.setRtn_mesg(e2.getMessage());
		//}
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** OOC - Report **/
	@Autowired
	private IOocReportService oocReportService;
	@ResponseBody
	@RequestMapping(value = "/ooc_report.do", method = RequestMethod.POST)
	public String ooc_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		OocReportBean reportBean = new OocReportBean();
		reportBean.setGridData(oocReportService.getGridData(conditions));
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** SPC - Report **/
	@Autowired
	private ISpcReportService spcReportService;
	@ResponseBody
	@RequestMapping(value = "/spc_report.do", method = RequestMethod.POST)
	public String spc_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		SpcReportBean reportBean = new SpcReportBean();
		reportBean.setGridData(spcReportService.getGridData(conditions));
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** SPC - CPK - Report **/
	@Autowired
	private ISpcCpkReportService spcCpkReportService;
	@ResponseBody
	@RequestMapping(value = "/spc_cpk_report.do", method = RequestMethod.POST)
	public String spc_cpk_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		SpcCpkReportBean reportBean = new SpcCpkReportBean();
		reportBean.setGridData(spcCpkReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** SPC - PPK - Report **/
	@Autowired
	private ISpcPpkReportService spcPpkReportService;
	@ResponseBody
	@RequestMapping(value = "/spc_ppk_report.do", method = RequestMethod.POST)
	public String spc_ppk_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		SpcPpkReportBean reportBean = new SpcPpkReportBean();
		reportBean.setGridData(spcPpkReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** SPC 控制线建议值- Report **/
	@Autowired
	private ISpcClReportService spcClReportService;
	@ResponseBody
	@RequestMapping(value = "/spc_cl_report.do", method = RequestMethod.POST)
	public String spc_cl_cpk_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		SpcClReportBean reportBean = new SpcClReportBean();
		reportBean.setGridData(spcClReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** SPC Chart - Report **/
	@Autowired
	private ISpcChartReportService spcChartReportService;
	@ResponseBody
	@RequestMapping(value = "/spc_chart_report.do", method = RequestMethod.POST)
	public String spc_chart_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		SpcChartReportBean reportBean = spcChartReportService.getGridData(conditions);
		reportBean.setEchartsData(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}

	/*** SPC Chart His- Report **/
	@Autowired
	private ISpcChartHisReportService spcChartHisReportService;
	@ResponseBody
	@RequestMapping(value = "/spc_chart_his_report.do", method = RequestMethod.POST)
	public String spc_chart_his_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		SpcChartHisReportBean reportBean = new SpcChartHisReportBean();
		reportBean.setGridData(spcChartHisReportService.getGridData(conditions));
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 稼动率 - Report **/
	@Autowired
	private IActivationReportService activationReportService;
	@Autowired
	private IActivation2ReportService activation2ReportService;
	@ResponseBody
	@RequestMapping(value = "/activation_report.do", method = RequestMethod.POST)
	public String activation_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		ActivationReportBean reportBean =  activation2ReportService.getGridData(conditions);
		//ActivationReportBean reportBean =  activationReportService.getGridData(conditions);
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 稼动率 - Report **/
	@Autowired
	private IActivationNewReportService activationNewReportService;
	@ResponseBody
	@RequestMapping(value = "/activation_new_report.do", method = RequestMethod.POST)
	public String activation_new_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		ActivationNewReportBean reportBean = new ActivationNewReportBean();
		reportBean.setGridData(activationNewReportService.getGridData(conditions));
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 稼动率原因代码 - Report **/
	@Autowired
	private IActivationRsnCodeReportService activationRsnCodeReportService;
	@ResponseBody
	@RequestMapping(value = "/activation_rsnCode_report.do", method = RequestMethod.POST)
	public String activation_rsnCode_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		ActivationRsnCodeReportBean reportBean = new ActivationRsnCodeReportBean();
		reportBean.setGridData(activationRsnCodeReportService.getGridData(conditions));
		reportBean.setGridDynamicColumn(conditions);
		reportBean.setDingDingGridData(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 扩散 - Report **/
	@Autowired
	private IKuosanReportService kuosanReportService;
	@ResponseBody
	@RequestMapping(value = "/kuosan_report.do", method = RequestMethod.POST)
	public String kuosan_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		KuosanReportBean reportBean = new KuosanReportBean();
		reportBean.setGridData(kuosanReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** IV工艺测试Chart图 - Report **/
	@Autowired
	private IIvTestChartReportService iIvTestChartReportService;
	@ResponseBody
	@RequestMapping(value = "/ivTest_chart_report.do", method = RequestMethod.POST)
	public String ivTest_chart_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		IvTestChartReportBean reportBean = iIvTestChartReportService.getGridData(conditions);
		reportBean.setEchartsData(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 维修单 - Report **/
	@Autowired
	private IRepairOrderReportService repairOrderReportService;
	@ResponseBody
	@RequestMapping(value = "/repairOrder_report.do", method = RequestMethod.POST)
	public String repairOrder_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		RepairOrderReportBean reportBean = new RepairOrderReportBean();
		reportBean.setGridData(repairOrderReportService.getGridData(conditions));
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 备品备件 - Report **/
	@Autowired
	private IMaterialReportService materialReportService;
	@ResponseBody
	@RequestMapping(value = "/material_report.do", method = RequestMethod.POST)
	public String material_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		MaterialReportBean reportBean = new MaterialReportBean();
		reportBean.setGridData(materialReportService.getGridData(conditions));
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** ERP领料信息 - Report **/
	@Autowired
	private IErpPickingReportService erpPickingReportService;
	@ResponseBody
	@RequestMapping(value = "/erpPicking_report.do", method = RequestMethod.POST)
	public String erpPicking_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		ErpPickingReportBean reportBean = new ErpPickingReportBean();
		reportBean.setGridData(erpPickingReportService.getGridData(conditions));
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** halm机测试-档位分布 - Report **/
	@Autowired
	private IHalmGearDistributionReportService halmGearDistributionReportService;
	@ResponseBody
	@RequestMapping(value = "/halm_gearDistribution_report.do", method = RequestMethod.POST)
	public String halm_gearDistribution_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		HalmGearDistributionReportBean reportBean = new HalmGearDistributionReportBean();
		reportBean.setGridData(halmGearDistributionReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		reportBean.computeSummaryData(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** halm机测试-Eta效能趋势 - Report **/
	@Autowired
	private IHalmEtaTrendReportService halmEtaTrendReportService;
	@ResponseBody
	@RequestMapping(value = "/halm_etaTrend_report.do", method = RequestMethod.POST)
	public String halm_etaTrand_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		HalmEtaTrendReportBean reportBean = new HalmEtaTrendReportBean();
		reportBean.setGridData(halmEtaTrendReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** halm机测试-各线效能 - Report **/
	@Autowired
	private IHalmLineEfficiencyReportService halmLineEfficiencyReportService;
	@ResponseBody
	@RequestMapping(value = "/halm_lineEfficiency_report.do", method = RequestMethod.POST)
	public String halm_lineEfficiency_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		HalmLineEfficiencyReportBean reportBean = new HalmLineEfficiencyReportBean();
		reportBean.setGridData(halmLineEfficiencyReportService.getGridData(conditions));
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** halm机测试-批次效能 - Report **/
	@Autowired
	private IHalmLotEfficiencyReportService halmLotEfficiencyReportService;
	@ResponseBody
	@RequestMapping(value = "/halm_LotEfficiency_report.do", method = RequestMethod.POST)
	public String halm_lotEfficiency_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		HalmLotEfficiencyReportBean reportBean = new HalmLotEfficiencyReportBean();
		reportBean.setGridData(halmLotEfficiencyReportService.getGridData(conditions));
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** halm机测试-颜色比例图表 - Report **/
	@Autowired
	private IHalmColorScaleReportService halmColorScaleReportService;
	@ResponseBody
	@RequestMapping(value = "/halm_colorScale_report.do", method = RequestMethod.POST)
	public String halm_colorScale_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		HalmColorScaleReportBean reportBean = new HalmColorScaleReportBean();
		reportBean.setGridData(halmColorScaleReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** halm机测试-小时效率趋势图表 - Report **/
	@Autowired
	private IHalmHourEfficiencyTrendReportService halmHourEfficiencyTrendReportService;
	@ResponseBody
	@RequestMapping(value = "/halm_hourEfficiencyTrend_report.do", method = RequestMethod.POST)
	public String halm_hourEfficiencyTrend_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		HalmHourEfficiencyTrendReportBean reportBean = new HalmHourEfficiencyTrendReportBean();
		reportBean.setGridData(halmHourEfficiencyTrendReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setEchartsData2(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** PECVD膜厚对比 - Report **/
	@Autowired
	private IPECVD1ReportService pecvd1ReportService;
	@ResponseBody
	@RequestMapping(value = "/pecvd_1_report.do", method = RequestMethod.POST)
	public String pecvd_1_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		PECVD1ReportBean reportBean = new PECVD1ReportBean();
		reportBean.setGridData(pecvd1ReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** PECVD膜厚等级比例 - Report **/
	@Autowired
	private IPECVD2ReportService pecvd2ReportService;
	@ResponseBody
	@RequestMapping(value = "/pecvd_2_report.do", method = RequestMethod.POST)
	public String pecvd_2_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		PECVD2ReportBean reportBean = new PECVD2ReportBean();
		reportBean.setGridData(pecvd2ReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** PECVD膜厚值分布 - Report **/
	@Autowired
	private IPECVD3ReportService pecvd3ReportService;
	@ResponseBody
	@RequestMapping(value = "/pecvd_3_report.do", method = RequestMethod.POST)
	public String pecvd_3_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		PECVD3ReportBean reportBean = new PECVD3ReportBean();
		reportBean.setGridData(pecvd3ReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** PECVD膜厚值ID查询 - Report **/
	@Autowired
	private IPECVD4ReportService pecvd4ReportService;
	@ResponseBody
	@RequestMapping(value = "/pecvd_4_report.do", method = RequestMethod.POST)
	public String pecvd_4_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		PECVD4ReportBean reportBean = new PECVD4ReportBean();
		reportBean.setGridData(pecvd4ReportService.getGridData(conditions));
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** PECVD不良分布 - Report **/
	@Autowired
	private IPECVD5ReportService pecvd5ReportService;
	@ResponseBody
	@RequestMapping(value = "/pecvd_5_report.do", method = RequestMethod.POST)
	public String pecvd_5_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		PECVD5ReportBean reportBean = new PECVD5ReportBean();
		reportBean.setGridData(pecvd5ReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		reportBean.setGridDynamicColumn(conditions);
		reportBean.computeSummaryData(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 2小时汇总 - Report **/
	@Autowired
	private ITwoHourSummaryReportService twoHourSummaryReportService;
	@ResponseBody
	@RequestMapping(value = "/twoHourSummary_report.do", method = RequestMethod.POST)
	public String twoHourSummary_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		TwoHourSummaryReportBean reportBean = new TwoHourSummaryReportBean();
		reportBean.setGridData(twoHourSummaryReportService.getGridData(conditions));
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 功率趋势Chart图 - Report **/
	@Autowired
	private IPowerTrendChartReportService powerTrendChartReportService;
	@ResponseBody
	@RequestMapping(value = "/powerTrend_chart_report.do", method = RequestMethod.POST)
	public String powerTrend_chart_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		PowerTrendChartReportBean reportBean = new PowerTrendChartReportBean();
		reportBean.setGridData(powerTrendChartReportService.getGridData(conditions));
		reportBean.setEchartsData(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 产品分类 - Report **/
	@Autowired
	private IProductClassifyReportService productClassifyReportService;
	@ResponseBody
	@RequestMapping(value = "/productClassify_report.do", method = RequestMethod.POST)
	public String productClassify_report(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		ProductClassifyReportBean reportBean = new ProductClassifyReportBean();
		reportBean.setGridData(productClassifyReportService.getGridData(conditions));
		reportBean.setGridDynamicColumn(conditions);
		return JacksonUtil.toJSONStr(reportBean);
	}


	/*** 异常耗时 - 监控 **/
	@Autowired
	private IAbnormalTimeMonitoringService abnormalTimeMonitoringService;
	@ResponseBody
	@RequestMapping(value = "/abnormalTime_monitoring.do", method = RequestMethod.POST)
	public String abnormalTime_monitoring(final String hashMapString) {
		ConditionBean conditions = getCondition(hashMapString);
		AbnormalTimeMonitoringBean monitoringBean = new AbnormalTimeMonitoringBean();
		monitoringBean.setGridData(abnormalTimeMonitoringService.getGridData(conditions));
		return JacksonUtil.toJSONStr(monitoringBean);
	}

}
